﻿using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
using EasyXaf.MongoDB;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System.ComponentModel;

namespace EasyXaf.Sample.Module.BusinessObjects;

[DomainComponent]
[MongoEntity]
[DefaultClassOptions]
[XafDisplayName("用户Flag")]
public class UserFlag : MongoEntity
{
    private string _name;

    public string Name
    {
        get => _name;
        set => SetPropertyValue(ref _name, value);
    }

    [Browsable(false)]
    [BsonGuidRepresentation(GuidRepresentation.Standard)]
    public Guid? UserId { get; set; }

    [BsonIgnore]
    [XafDisplayName("用户")]
    [MongoForeignKey(nameof(UserId))]
    public ApplicationUser User
    {
        get => GetEntity<ApplicationUser>();
        set => SetEntity(value);
    }
}
